package com.codingke.codingbookstore.ui;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.codingke.codingbookstore.App;
import com.codingke.codingbookstore.R;
import com.codingke.codingbookstore.utils.AppUtils;
import com.codingke.codingbookstore.utils.Constant;
import com.codingke.codingbookstore.vo.Address;
import com.codingke.codingbookstore.vo.Orders;

public class OrderItemActivity extends BaseActivity {

    private TextView textView6_order_status;//订单状态
    private TextView textView6_wuliu_name;//物流名称
    private TextView textView6_wuliu_number;//物流编号
    private TextView textView6_buyDate;//下单日期
    private TextView textView6_order_id;//订单号
    private TextView textView6_address;//收货地址
    private TextView textView6_username;//收货人
    private TextView textView6_phoneNumber; //手机号
    private TextView textView6_receiver_time;//收货时间
    private TextView textView6_invoice_type; //发票类型
    private TextView textView6_invoice_title; //发票抬头
    private ImageView textView5_bookimage; //书图片
    private TextView textView5_count; //数量
    private TextView textView5_discount_price; //单价
    private TextView textView5_total; //总金额
    private TextView textView5_freight; //运费
    private TextView textView5_amount_payable; //应付金额
    private TextView textView5_bookname; //书名
    private Orders orders;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_item);
        orders = (Orders) getIntent().getSerializableExtra("orders");
        if(orders==null){
            finish();
        }
        initView();
        initData();
    }

    private void initData() {
        textView6_order_status.setText(AppUtils.getStatus(orders.getStatus()));
        textView6_buyDate.setText(orders.getBuyDate());
        textView6_order_id.setText(orders.getOrderId());
        Address a = orders.getAddress();
        textView6_address.setText(a.getAddress());
        textView6_username.setText(a.getUsername());
        textView6_phoneNumber.setText(a.getPhoneNumber());
        textView5_bookname.setText(orders.getBookName());
        App.bitmapUtils.display(textView5_bookimage, Constant.BMOBFILE_ROOT+orders.getBookImage());
        textView5_count.setText("数量 x"+orders.getTotal());
        textView5_discount_price.setText("单价:"+orders.getDiscountPrice());
        textView5_total.setText("订单总额:"+(orders.getSubtotal()));
        textView5_freight.setText("运费:"+orders.getFreight());
        textView5_amount_payable.setText("应付金额:"+(orders.getSubtotal()+orders.getFreight()));
    }

    private void initView() {
        textView6_order_status = (TextView) findViewById(R.id.textView6_order_status);
        textView6_wuliu_name = (TextView) findViewById(R.id.textView6_wuliu_name);
        textView6_wuliu_number = (TextView) findViewById(R.id.textView6_wuliu_number);
        textView6_buyDate = (TextView) findViewById(R.id.textView6_buyDate);
        textView6_order_id = (TextView) findViewById(R.id.textView6_order_id);
        textView6_address = (TextView) findViewById(R.id.textView6_address);
        textView6_username = (TextView) findViewById(R.id.textView6_username);
        textView6_phoneNumber = (TextView) findViewById(R.id.textView6_phoneNumber);
        textView6_receiver_time = (TextView) findViewById(R.id.textView6_receiver_time);
        textView6_invoice_type = (TextView) findViewById(R.id.textView6_invoice_type);
        textView6_invoice_title = (TextView) findViewById(R.id.textView6_invoice_title);
        textView5_bookimage = (ImageView) findViewById(R.id.textView5_bookimage);
        textView5_count = (TextView) findViewById(R.id.textView5_count);
        textView5_bookname = (TextView) findViewById(R.id.textView5_bookname);
        textView5_discount_price = (TextView) findViewById(R.id.textView5_discount_price);
        textView5_total = (TextView) findViewById(R.id.textView5_total);
        textView5_freight = (TextView) findViewById(R.id.textView5_freight);
        textView5_amount_payable = (TextView) findViewById(R.id.textView5_amount_payable);
    }
}
